/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.company.primitivies;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * @author admin
 */
public class Ellipse {

    private double a;
    private double b;
    private double c;
    private double e;

    public double getC() {
        return c;
    }

    public double getB() {
        return b;
    }

    public Ellipse(double a, double b) {
        this.a = a;
        this.b = b;
        this.c = Math.sqrt(a * a - b * b);
        this.e = c / a;
    }

    public double getE() {
        return e;
    }

    public double genX(double t) {
        return a * Math.cos(t);
    }

    public double genY(double t) {
        return b * Math.sin(t);
    }

    public Map<Double, Point2d> generatePoint(double h) {
        Map<Double, Point2d> result = new HashMap<>();
        double t = 0;
        while (t <= 2 * Math.PI) {
            result.put(t, new Point2d(genX(t), genY(t)));
            t = t + h;
        }
        return result;
    }

    public List<Point2d> generateListPoint(double h) {
        List<Point2d> result = new ArrayList<>();
        double t = 0;
        while (t <= 2 * Math.PI) {
            result.add(new Point2d(genX(t), genY(t)));
            t = t + h;
        }
        return result;
    }
}
